package com.cy.ajax.controller;

import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

@RestController
public class AjaxLibController {
    @PostMapping("doPost")
    public String doPost(@RequestParam Map<String, Object> map) {
        System.out.println(map);
        return "post ok";
    }
    @PostMapping("doPostJSON")
    @CrossOrigin
    public String doPostJSON(@RequestBody Map<String, Object> map) {
        System.out.println(map);
        return "post ok";
    }

    @GetMapping("doGet")
    public Map<String, Object> doGet(){
        Map<String, Object> map = new HashMap<>();
        map.put("code", 1);
        map.put("message", "success");
        return map;
    }
    @RequestMapping("doAjax")
    public String doAjax(String msg) {
        System.out.println("msg" + msg);
        return "toupCase" + msg.toUpperCase();
    }
}
